#include <cstdio>
#include <algorithm>
using namespace std;
int t;
int a,b,c,d;
int main(void){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        int e=a*d+b*c;
        int f=b*d;
        int g=__gcd(e,f);
        e/=g;
        f/=g;
        printf("%d %d\n",e,f);
    }
    return 0;
}